/*
 * Copyright 2008 Lucifer Lu
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

using System;
using System.Collections.Generic;
using SilverChart.Core.Configuration;
using SilverChart.Core.Service;

namespace SilverChart.Configuration {
    /// <summary>
    /// Description of Elements.
    /// </summary>
    [ServiceProvider(Singleton = false, ServiceName = "Configuration Items: Element")]
    [ConfigurationItem(Configurations.ITEM_NAME_ELEMENT)]
    public class Element : AbstractConfigurationItem {
        public const String ITEM_NAME_TYPE = "type";
        public ChartType DefaultType = ChartType.Unknown;
        private ValueItemHelper<ChartType> type;

        public const String ITEM_NAME_SHOWTIP = "show_tip";
        public Boolean DefaultShowTip = true;
        private ValueItemHelper<Boolean> showTip;

        public const String ITEM_NAME_VALUES = "values";
        public const String ITEM_NAME_VALUES_ELEMENT = "value";
        public const Boolean DefaultCreateValuesArray = true;
        private ValueItemHelper<IList<Double>> values;

        public const String ITEM_NAME_LEGENDNAME = "legend_name";
        public const String DefaultLegendName = null;
        private StringValueItemHelper legendName;

        public Element(ConfigurationParser parser)
            : base(parser) {
            type = new SimpleValueItemHelper<ChartType>(this, ITEM_NAME_TYPE, DefaultType);
            showTip = new SimpleValueItemHelper<Boolean>(this, ITEM_NAME_SHOWTIP, DefaultShowTip);

            values = new ArrayValueItemHelper<Double>(this, ITEM_NAME_VALUES, ITEM_NAME_VALUES_ELEMENT, DefaultCreateValuesArray);
            legendName = new StringValueItemHelper(this, ITEM_NAME_LEGENDNAME, DefaultLegendName);
        }

        public ChartType ChartType { get { return type.Value; } }
        public Boolean ShowTip { get { return showTip.Value; } }

        public IList<Double> Values { get { return values.Value; } }

        public String LegendName { get { return legendName.Value; } }

        ////[JsonProperty("fill_color")]
        //public String Fill { get; set; }

        ////[JsonProperty("fill_start_color")]
        //public String GradientStartColor { get; set; }

        ////[JsonProperty("fill_end_color")]
        //public String GradientEndColor { get; set; }

        ////[JsonProperty("fill_type")]
        //public String _FillType {
        //    get {
        //        return _fillType.ToString();
        //    }
        //    set {
        //        switch (value.ToLower()) {
        //            case "solid":
        //                _fillType = FillType.Solid;
        //                break;
        //            case "gradient":
        //                _fillType = FillType.Gradient;
        //                break;
        //            default:
        //                _fillType = FillType.Solid;
        //                break;
        //        }
        //    }
        //}

        //public FillType FillType {
        //    get {
        //        return _fillType;
        //    }
        //    set {
        //        _fillType = value;
        //    }
        //}
    }
}
